package cn.edu.xmu.javaee.productwebflux.controller;

import cn.edu.xmu.javaee.productwebflux.service.ProductService;
import cn.edu.xmu.javaee.productwebflux.service.vo.ProductVo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.server.ServerRequest;
import reactor.core.publisher.Mono;

@Component
@RequiredArgsConstructor
public class AdminProductHandler {

    private final ProductService productService;

    public Mono<ProductVo> getProductById(ServerRequest request) {
        Long id = Long.parseLong(request.pathVariable("id"));
        Long shopId = Long.parseLong(request.pathVariable("shopId"));
        return this.productService.getDraft(shopId, id);
    }
}
